//
//  globalConfiguration.h
//  IPCamera
//
//  Created by joker on 15/8/25.
//  Copyright (c) 2015年 Andon Health Co,.Ltd. All rights reserved.
//

#ifndef IPCamera_globalConfiguration_h
#define IPCamera_globalConfiguration_h

#define _TEST_VIDEO_
#define _TEST_AUDIO_

    //MARK: 以下为音频部分的设置常量
#define QUEUE_BUFFER_SIZE   (3)
#define AUDIO_BUF_SIZE  (4096)

    //如果摄像机的固件更新后, 将下面第一行注释掉, 取消第二行注释
#define PADDINGBITS     (24)
    //#define PADDINGBITS     (0)



#define PRINTERROR(LABEL)	printf("%s err %4.4s %ld\n", LABEL, (char *)&err, err)

static const unsigned int kNumAQBufs = QUEUE_BUFFER_SIZE;			// number of audio queue buffers we allocate
static const size_t kAQBufSize = AUDIO_BUF_SIZE;		// number of bytes in each audio queue buffer

struct MyData
{
    AudioFileStreamID audioFileStream;	// the audio file stream parser
    
    AudioQueueRef audioQueue;								// the audio queue
    AudioQueueBufferRef audioQueueBuffer[kNumAQBufs];		// audio queue buffers
    
    AudioStreamPacketDescription packetDescs;	// packet descriptions for enqueuing audio
    
    unsigned int fillBufferIndex;	// the index of the audioQueueBuffer that is being filled
    size_t bytesFilled;				// how many bytes have been filled
    size_t packetsFilled;			// how many packets have been filled
    
    bool inuse[kNumAQBufs];			// flags to indicate that a buffer is still in use
    bool started;					// flag to indicate that the queue has been started
    bool failed;					// flag to indicate an error occurred
    
    pthread_mutex_t mutex;			// a mutex to protect the inuse flags
    pthread_cond_t cond;			// a condition varable for handling the inuse flags
    pthread_cond_t done;			// a condition varable for handling the inuse flags
    
    int channelIndex;

    
};
typedef struct MyData MyData;

#endif
